import { Pagination } from "antd";
import { PaginationProps } from "antd/es/pagination/Pagination";
interface WidgetPaginatinProps extends Object{
    page:number,
    total:number,
    size:number,
    handlerCurrentPageSize:(current:number,pageSize:number) => void
}
const WidgetPaginatin = (props:WidgetPaginatinProps) => {
    const onChange: PaginationProps['onChange'] = (page,size) => {
        props.handlerCurrentPageSize(page,size);
      };
    return(
        <div className="widget-patition">
            <Pagination 
            pageSize={props.size} 
            current={props.page} 
            total={props.total} 
            defaultCurrent={1}
            onChange={onChange}/>
        </div>
    )
}
export function InitPagition(handlerCurrentPageSize:Function) :WidgetPaginatinProps{
    return {
        page: 1,
        total: 0,
        size: 20,
        handlerCurrentPageSize: handlerCurrentPageSize()
    }
}

export default WidgetPaginatin;
export  type{WidgetPaginatinProps};